package com.haumeasoft.snake.os.client.view;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

import com.haumeasoft.snake.os.client.R;
import com.haumeasoft.snake.os.client.helpers.PostAsyncTask;
import com.haumeasoft.snake.os.client.model.PostParameters;
import com.haumeasoft.snake.os.client.model.SnakeConstants;

/**
 * A dummy fragment representing a section of the app, but that simply displays
 * dummy text.
 */
public class StatusFragment extends Fragment {
	

	public StatusFragment() {
	}

	public static final String ARG_SECTION_NUMBER = "section_number";

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View fragmetView = inflater.inflate(R.layout.status_fragment, container, false);
		Button rebootButton = (Button) fragmetView.findViewById(R.id.rebootButton);
		rebootButton.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				// prepare the post parameters for the reboot call
				PostParameters postParameters = new PostParameters();
				postParameters.setUrl(SnakeConstants.SNAKE_STATUS_ADDRES);
				postParameters.getParameters().put("reboot", "Reboot");
				
				// do post call for the reboot
				new PostAsyncTask().execute(postParameters);
			}
		});
		return fragmetView;
	}


}
